import { createStoreBindings } from 'mobx-miniprogram-bindings'
import { store } from '../../store/store'
const utils = require('../../utils/util')

Page({
  onLoad() {
    this.storeBindings = createStoreBindings(this, {
      store,
      fields: ['token', 'FIL', 'USDT', 'productList'],
      actions: ['getWallet', 'getProduct']
    })
  },
  onReady() {
    utils.checktoken(this.data.token, () => {
      if (JSON.stringify(this.data.FIL) == '{}') {
        this.getWallet('FIL')
      }
      if (JSON.stringify(this.data.USDT) == '{}') {
        this.getWallet('USDT')
      }
      if (this.data.productList.length == 0) {
        this.getProduct()
      }
    })
  },
  onUnload() {
    this.storeBindings.destroyStoreBindings()
  }
})
